Skip to content

feat(desktop): show the installed apps each style applies to - #287

Merged
hadrysm merged 12 commits into
feat/style-per-categoryfrom
feat/style-app-banners
Oct 16, 2026
Merged

hadrysm merged 12 commits into
feat/style-per-categoryfrom
feat/style-app-banners

Conversation

@hadrysm

@hadrysm hadrysm commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Part of #281

Why

Each Style tab described its category in a fixed caption, such as "Used in workplace messengers like Slack and Teams." The caption named example apps whether or not they were installed, so the user could not see where a style would apply on their own Mac.

Each tab now shows a banner: "This style applies in personal messengers" (workplace messengers, all major email apps, all other apps), followed by the real icons of the installed apps in that category. Up to four icons show, then "+N". The helper lists the installed apps and renders the icons, and main caches the icons in memory.

Scope

  • Helper, protocol 12. apps.list scans /Applications, /System/Applications and ~/Applications, plus one level of plain subfolders such as Utilities. It reads each Info.plist directly and answers apps.listed { apps: { bundleId, name, path, modifiedMs, browser }[] }. browser is true for the apps the helper reads a page host from, so the app owns the browser list alone, where modifiedMs is the later of the bundle directory's and its Info.plist's modification times. The name is CFBundleDisplayName, then CFBundleName, then the file name. Bundles without an id are skipped. icons.render { id, paths } draws NSWorkspace.shared.icon(forFile:) into 64x64 PNGs and answers icons.rendered { id, icons: { path, png }[] }, so main matches each reply to its request. Both commands run on a utility queue. The pure plist-to-entry function, installedApp(info:path:), lives in VoiceHelperCore.
  • main/protocol.ts: version 12 and the two events. A malformed entry is dropped while decoding, and the rest of the list survives.
  • main/installed-apps.ts: main asks for the list only when the hub calls getInstalledApps, never at startup. list() lowercases and dedupes bundle ids and returns without waiting for any icon. icons(bundleIds) renders the icons a tile asks for, in helper lines of at most 32 paths, and leaves out any the helper could not render. Icons stay in memory, keyed by path, and are reused only while the latest list has the same path with the same modifiedMs, so an app updated in place or reinstalled gets its new icon, and removed apps are dropped from the cache on every list. Each render reply is matched to its request by id; a reply to a timed-out request is dropped. Concurrent list calls share one request. If the helper does not answer within 5 s, the list rejects and the page shows no icons. The next open starts over.
  • shared/api.ts: InstalledApp = { bundleId: BundleId; name: string; browser: boolean }, HubApi.getInstalledApps() and HubApi.getAppIcons(bundleIds), which returns PNG data URLs by bundle id. Paths never reach the renderer.
  • shared/app-categories.ts: parseBundleIds(raw) reads the bundle ids out of the untrusted IPC argument. PR 6 leaves browsers out of its picker by the helper's browser flag; there is no TS copy of the browser list.
  • renderer/styleView.ts, Style.tsx, useInstalledApps.ts, AppIcon.tsx, appIcons.ts: the banner shows the installed apps of the tab's category in catalog order, using the catalog's display names, and an app installed under two catalog ids (classic and new Teams) once. Each AppIcon tile asks for its own icon through useAppIcon(bundleId); the tiles mounted in one tick share one getAppIcons call, an icon stays in the renderer while the window is open, and an id the helper could not render is forgotten so a later mount asks again. A tile shows the app's first letter until its icon arrives, or when the image fails to load. Each icon has the app name as its accessible name and its tooltip. "+N" names the hidden apps in its label and tooltip. Other shows no icons. The page fetches the list once each time it opens.
  • Verify docs: features/style.md describes the banners.
  • Out of scope: icons for sites, favicons, bundled brand logos, and the "+" picker (PR 6).

Tradeoffs

  • The helper renders the icons because Electron's app.getFileIcon cannot. On this Mac (macOS 27, Electron 44) it returns the same generic placeholder for every .app: Messages, Slack, Mail, WhatsApp, Discord, Teams and Terminal all gave byte-identical PNGs. size: "large" crashed Electron with SIGTRAP. NSWorkspace.shared.icon(forFile:) returns the real icon.
  • Icons are rendered per tile, on request, because the banner needs about six and PR 6's picker will need a hundred. The list never waits for a render, so a stalled helper cannot blank the page, and nothing is rendered for an icon no one sees.
  • Render replies carry the request id. A reply that arrives after its 5 s timeout is dropped, so it can never complete a later request. The timeout is the way out when the helper drops a command during a restart.
  • Banner names come from the catalog, not the bundle, so Zoom reads "Zoom" rather than "zoom.us". WhatsApp's bundle display name starts with a left-to-right mark (U+200E). The helper strips control and format characters from names, and a Swift test covers that case.

Blast Radius

The helper and the app refuse each other across the version bump, as they already do. native/voice-helper/scripts/helper.mjs pins version 12. Nothing new runs at startup or during dictation. Opening Style sends one apps.list, plus one icons.render the first time. The installed-app list is never logged or persisted.

Verification

  • swift test --filter 'InstalledApp|Protocol': 17 tests pass. They cover id present, missing, blank or not a string; the display name, CFBundleName and file-name fallbacks; a padded name; and the exact JSON of both commands and both events.
  • vp test run on protocol.test.ts, installed-apps.test.ts, styleView.test.ts, app-categories.test.ts, style.test.ts, hub.test.ts, helper.test.ts and dictation.test.ts: 262 tests pass. tsc --noEmit passes. The tests cover:
    • decoding a list with one malformed entry, which drops only that entry, for both events;
    • a first open that renders icons for catalog apps only;
    • a second open that reuses the cached icons and sends no icons.render;
    • a moved or newly installed catalog app, whose path alone is rendered;
    • an app replaced in place (new modifiedMs) and an app removed then reinstalled at the same path, both rendered again;
    • lowercasing and deduping bundle ids;
    • single-flight requests, and the timeout followed by a fresh retry;
    • catalog order, the "+2" overflow with six personal apps, a letter when the icon is null, Other showing nothing, and the browser mirror.
  • Real binary, run directly: apps.list returns 105 bundles, including Terminal from /System/Applications/Utilities. icons.render drops a missing path and returns real 64x64 Slack and Mail icons.
  • Live app in test mode, with the verify skill and the real helper. These are the actual installed apps on this Mac:
    • Personal shows Messages, WhatsApp and Discord.
    • Work shows Slack and Microsoft Teams.
    • Email shows Mail.
    • Other shows no icons.
    • The accessible names read ["Messages","WhatsApp","Discord"].
  • Timing, getInstalledApps round trip from the renderer: 132 ms on the first open (list plus 6 icons), and 14 ms on each of three later opens (list only, icons cached). The helper alone measured 89 ms for a cold apps.list and 12 to 15 ms for a cold 2-icon icons.render.
  • Idle stays idle. I counted the commands main writes to the helper's stdin by hooking it through the main-process inspector. Results:
    • 60 s on the Style page sent 0 apps.list.
    • Three tab switches sent 0.
    • Going to Home and back to Style sent 1 apps.list and 0 icons.render.
    • 30 s more on the page sent nothing.
  • main.log has no app name or path.
  • I could not check "+N" live, because this Mac has only three personal apps installed. The unit test covers it.

Personal, Work, Email and Other:

style-personal.png
style-work-messages.png
style-email.png
style-other.png

Review round 2

Changed after review (reports 04, 06, 07): protocol 12 is defined once, with icons.render { id, paths } and icons.rendered { id, icons } here instead of in PR 6, and apps.listed entries carry browser from the helper's own list, which deletes the TS BROWSER_BUNDLE_IDS mirror and its Swift-source regex test. list() no longer waits for a render; icons became a per-tile concern (AppIcon.tsx, appIcons.ts) over a new getAppIcons channel, with main rendering at most 32 paths per helper line. The module-global listedStamps is gone: the cache is written from the stamps of the list the request was built on. The banner dedupes a name shipped under two ids, installedApps is declared before startHelper like dictation, parseBundleIds parses the IPC argument, and the fake helper answers apps.list and icons.render.

Proof: swift build and swift test --filter 'InstalledAppTests|Protocol' (12 tests) pass; tsc --noEmit passes; vp test run on installed-apps, protocol, appIcons, styleView, style, hub and helper tests passes (150 tests), including a render split into 32 + 3 paths, a late reply to a timed-out render that does not complete the next one, an unrenderable id asked for again on the next request, same-tick batching, and the Teams dedupe (the test fails when the dedupe guard is removed). The real helper lists 105 apps and flags Google Chrome, Helium and Safari as browsers. Live, in test mode with the real helper: Personal shows Messages, WhatsApp and Discord, Work shows Slack and Microsoft Teams, Email shows Mail, Other shows none, all as <img> tiles with the app name as the accessible name; getInstalledApps 90 ms, 40 cold icons 475 ms in two helper lines, the same 40 warm 5 ms; main.log has no app path. dictate was not run; it is out of this change's path.

style-personal-r2.png
style-work-messages-r2.png

Opening Style, round 2:

style-open-r2.mp4

Switching tabs (round 1):

style-banners.mp4

Review round 3

Changed after round 2 (reports 08 and 09): an icon asked for before the first installed-app list completed got {} and never retried, so a chip mounted from saved settings on a cold open stayed a letter. icons() in main now waits for the list in flight, or runs the first one, before resolving paths, and returns {} only when that list fails. The renderer's icon memo used to keep the first PNG for the life of the window, which defeated main's path-and-stamp freshness after an app update. The memo now carries a generation: listInstalledApps() in appIcons.ts lists and then invalidates, a stale icon stays on show until its refetch replaces it, and useAppIcon subscribes to the loader so a mounted tile re-requests after each list. The helper's second isBrowser overload is gone; the installed-app scan calls PR 5's optional one.

Proof: vp test run on installed-apps, appIcons and styleView passes (27 tests). The six new tests were red on the previous head ({} against Mail's icon in main; no invalidate or subscribe on the loader) and cover an icon asked for while the first list is in flight, before any list, and when the list never arrives; invalidation keeping the icon on show and refetching once; a stale icon forgotten when the refetch leaves it out; and, through the real createIconLoader over the real createInstalledApps, an app updated in place keeping icon-v1 on show until icon-v2 arrives, plus a remount after an unchanged list that asks main and gets memory, with no new icons.render. tsc --noEmit, vp lint and vp fmt --check pass on the changed files. swift build and swift test --filter InstalledApp (8 tests) pass. Live, in test mode with the real helper and the desktop lock: Personal shows Messages, WhatsApp and Discord as <img> tiles on open, Work adds Slack and Microsoft Teams, and after Home and back to Style the three Personal tiles are <img> again. main.log has no app path or name. dictate was not run; it is outside this change's path and the user's Voice.app was running.

r3-style-open.png
r3-style-back.png

Review round 4

Changed after round 3 (report 10): a list that completed while an icon request was in flight invalidated the memo, but the mounted tile got the old request back and nothing asked for the current list afterwards, so an updated icon could stay old or a missing one stay a letter. The answer to an obsolete request still shows, since it is never older than what it replaces, and the load goes on to ask for the current list. Proof: four new loader tests (obsolete answer with an icon, with no icon, and failing; and a second invalidation during the follow-up) were red on the previous head and pass now, with the hook's subscribe-then-load wiring. Live, Personal still shows Messages, WhatsApp and Discord as <img> tiles on open and after Home and back.

r4-style-back.png

@github-actions github-actions Bot added the size:XL 500-999 effective changed lines (test files excluded in mixed PRs). label Oct 16, 2026
@hadrysm
hadrysm added this pull request to stack #290 October 16, 2026 08:33
@hadrysm
hadrysm force-pushed the feat/style-app-banners branch 2 times, most recently from d5dccea to 10215d0 Compare October 16, 2026 09:32
The Style page cannot show which installed apps a style applies to, because
nothing lists installed apps. Electron's app.getFileIcon cannot supply the icons
either: on macOS 27 it returns one generic placeholder for every .app, and size
"large" crashes Electron.

Protocol 12 adds apps.list and icons.render. The helper scans /Applications,
/System/Applications and ~/Applications, plus one level of plain subfolders,
reads each Info.plist directly, and draws NSWorkspace icons into 64x64 PNGs,
all on a utility queue. Main asks for the list only when the hub calls
getInstalledApps, lowercases and dedupes bundle ids, and asks for icons only
for catalog apps it has not rendered yet. Icons stay in memory for the life of
main. A malformed list entry is dropped and the rest kept. If the helper does
not answer within five seconds, the list rejects and the next call starts over.

BROWSER_BUNDLE_IDS mirrors the helper's browser list for the coming app picker,
and a test keeps the two equal.
Each Style tab described its category in a fixed caption that named example apps whether or not they were installed.

Each tab now reads "This style applies in personal messengers" (workplace messengers, all major email apps, all other apps) followed by the icons of the matching installed apps, in catalog order. Up to four show, and "+N" names the rest in its tooltip and accessible label. An app without an icon, or whose icon fails to load, shows its first letter. The list is fetched once each time the page opens, and a failure shows no icons.
The icon cache was keyed by path alone, so an app that updated its icon in
place, or was removed and reinstalled at the same path, kept its old icon until
Voice restarted, and removed apps were never evicted.

Each apps.listed entry now carries modifiedMs, the later of the bundle
directory's and its Info.plist's modification times. Main keeps an icon only
while the latest list has the same path with the same modifiedMs, and drops
every other cached icon on each list. Protocol 12 is unreleased, so the field
joins it without a bump.
@hadrysm
hadrysm force-pushed the feat/style-app-banners branch from 0ce3fa2 to 8415cc7 Compare October 16, 2026 10:49
…its fetch

A list that completed while an icon request was in flight invalidated the memo, but the mounted tile got the old request back and nothing asked for the current list afterwards. The answer to an obsolete request still shows, and the load goes on to ask for the current list.
@hadrysm
hadrysm merged commit 6808960 into main Oct 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 effective changed lines (test files excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant